Skip to content

Add Spring Cloud Stream retry support to ServiceBus Binder#47149

Merged
rujche merged 26 commits intomainfrom
copilot/fix-servicebus-backoff-settings
Apr 28, 2026
Merged

Add Spring Cloud Stream retry support to ServiceBus Binder#47149
rujche merged 26 commits intomainfrom
copilot/fix-servicebus-backoff-settings

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 4, 2025

This pull request adds robust retry support for message processing failures in the spring-cloud-azure-stream-binder-servicebus module. It introduces support for Spring Cloud Stream consumer retry properties (such as maxAttempts, backOffInitialInterval, backOffMaxInterval, and backOffMultiplier), enables exponential backoff for retries, and allows injection of a custom RetryTemplate for advanced scenarios. The changes also include comprehensive tests to verify the new retry logic and its configurability.

New Retry Support for Service Bus Stream Binder:

Feature Additions:

  • Added support for configuring retry behavior on message processing failures using standard Spring Cloud Stream consumer properties (maxAttempts, backOffInitialInterval, backOffMaxInterval, backOffMultiplier) for exponential backoff [1]], [2]], [3]]).
  • Enabled injection of a custom RetryTemplate bean (named serviceBusRetryTemplate) for advanced retry scenarios [1]], [2]], [3]], [4]]).

Dependency Updates:

  • Added the spring-retry dependency to the module and updated the dependency management and banned dependencies configuration [1]], [2]]).

Configuration and Integration:

  • Updated the binder configuration to wire an optional custom RetryTemplate bean into the ServiceBusMessageChannelBinder [1]], [2]]).

Test Coverage:

  • Added comprehensive tests to verify retry template creation, property mapping, use of custom templates, and correct disabling of retry when maxAttempts is 1 [1]], [2]]).

These enhancements provide more reliable and configurable message processing for Service Bus consumers, supporting both standard and advanced retry scenarios.

Copilot AI and others added 4 commits November 4, 2025 06:03
Implement support for Spring Cloud Stream's consumer retry properties:
- back-off-initial-interval
- back-off-max-interval
- back-off-multiplier
- max-attempts

Changes:
- Added RetryTemplate support to ServiceBusInboundChannelAdapter
- Created RetryTemplate based on consumer properties in ServiceBusMessageChannelBinder
- Wrapped message sending with retry logic when maxAttempts > 1
- Added comprehensive tests for retry behavior
- Maintained backward compatibility (no retry when maxAttempts = 1)

Co-authored-by: saragluna <31124698+saragluna@users.noreply.github.com>
- Updated CHANGELOG.md for both ServiceBus binder and integration modules
- Created comprehensive RETRY_CONFIGURATION.md guide
- Documented configuration properties, behavior, examples, and best practices

Co-authored-by: saragluna <31124698+saragluna@users.noreply.github.com>
Addressed code review feedback to remove extra blank line before closing brace

Co-authored-by: saragluna <31124698+saragluna@users.noreply.github.com>
… creation

Addressed code review feedback to avoid anonymous inner class memory leak by using explicit HashMap creation instead of double-brace initialization

Co-authored-by: saragluna <31124698+saragluna@users.noreply.github.com>
Copilot AI changed the title [WIP] Make ServiceBus Binder honor Spring Stream back-off settings Add Spring Cloud Stream retry support to ServiceBus Binder Nov 4, 2025
Copilot AI requested a review from saragluna November 4, 2025 06:17
Allow users to inject a custom RetryTemplate from Spring context via
setRetryTemplate() method. When provided, the custom template takes
precedence over the auto-created one from consumer properties.

Changes:
- Added retryTemplate field to ServiceBusMessageChannelBinder
- Added setRetryTemplate() setter method
- Modified createConsumerEndpoint to use injected template if available
- Added test to verify custom RetryTemplate is used
- Updated documentation with custom RetryTemplate example
- Updated CHANGELOG with new feature

Co-authored-by: saragluna <31124698+saragluna@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Nov 5, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • login.microsoftonline.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java -javaagent:/home/REDACTED/.m2/repository/org/jacoco/org.jacoco.agent/0.8.13/org.jacoco.agent-0.8.13-runtime.jar=destfile=/home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-autoconfigure/target/jacoco-unit.exec,excludes=META-INF/** -Xmx4096m -XX:&#43;HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-autoconfigure/target/spring-cloud-azure-autoconfigure-oom.hprof -XX:&#43;CrashOnOutOfMemoryError --add-opens java.base/java.lang.invoke=com.azure.core org.apache.maven.surefire.booter.ForkedBooter /home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-autoconfigure/target/surefire 2025-11-05T03-31-25_112-jvmRun1 surefire-20251105033248445_37tmp surefire_12-20251105033248445_38tmp (dns block)
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java -javaagent:/home/REDACTED/.m2/repository/org/jacoco/org.jacoco.agent/0.8.13/org.jacoco.agent-0.8.13-runtime.jar=destfile=/home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-autoconfigure/target/jacoco-unit.exec,excludes=META-INF/** -Xmx4096m -XX:&#43;HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-autoconfigure/target/spring-cloud-azure-autoconfigure-oom.hprof -XX:&#43;CrashOnOutOfMemoryError --add-opens java.base/java.lang.invoke=com.azure.core org.apache.maven.surefire.booter.ForkedBooter /home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-autoconfigure/target/surefire 2025-11-05T03-38-45_939-jvmRun1 surefire-20251105033958921_31tmp surefire_12-20251105033958921_32tmp (dns block)
  • oss.jfrog.org
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.11/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.11/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.11 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.11/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring org.codehaus.plexus.classworlds.launcher.Launcher clean compile -pl spring-cloud-azure-stream-binder-servicebus -am -DskipTests (dns block)
  • sample-propertysource.vault.azure.net
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java -javaagent:/home/REDACTED/.m2/repository/org/jacoco/org.jacoco.agent/0.8.13/org.jacoco.agent-0.8.13-runtime.jar=destfile=/home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-autoconfigure/target/jacoco-unit.exec,excludes=META-INF/** -Xmx4096m -XX:&#43;HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-autoconfigure/target/spring-cloud-azure-autoconfigure-oom.hprof -XX:&#43;CrashOnOutOfMemoryError --add-opens java.base/java.lang.invoke=com.azure.core org.apache.maven.surefire.booter.ForkedBooter /home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-autoconfigure/target/surefire 2025-11-05T03-31-25_112-jvmRun1 surefire-20251105033248445_37tmp surefire_12-20251105033248445_38tmp (dns block)
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java -javaagent:/home/REDACTED/.m2/repository/org/jacoco/org.jacoco.agent/0.8.13/org.jacoco.agent-0.8.13-runtime.jar=destfile=/home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-autoconfigure/target/jacoco-unit.exec,excludes=META-INF/** -Xmx4096m -XX:&#43;HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-autoconfigure/target/spring-cloud-azure-autoconfigure-oom.hprof -XX:&#43;CrashOnOutOfMemoryError --add-opens java.base/java.lang.invoke=com.azure.core org.apache.maven.surefire.booter.ForkedBooter /home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-autoconfigure/target/surefire 2025-11-05T03-38-45_939-jvmRun1 surefire-20251105033958921_31tmp surefire_12-20251105033958921_32tmp (dns block)
  • sample.servicebus.windows.net
  • sample.somelocation.eventgrid.azure.net
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java -javaagent:/home/REDACTED/.m2/repository/org/jacoco/org.jacoco.agent/0.8.13/org.jacoco.agent-0.8.13-runtime.jar=destfile=/home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-autoconfigure/target/jacoco-unit.exec,excludes=META-INF/** -Xmx4096m -XX:&#43;HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-autoconfigure/target/spring-cloud-azure-autoconfigure-oom.hprof -XX:&#43;CrashOnOutOfMemoryError --add-opens java.base/java.lang.invoke=com.azure.core org.apache.maven.surefire.booter.ForkedBooter /home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-autoconfigure/target/surefire 2025-11-05T03-31-25_112-jvmRun1 surefire-20251105033248445_37tmp surefire_12-20251105033248445_38tmp (dns block)
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java -javaagent:/home/REDACTED/.m2/repository/org/jacoco/org.jacoco.agent/0.8.13/org.jacoco.agent-0.8.13-runtime.jar=destfile=/home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-autoconfigure/target/jacoco-unit.exec,excludes=META-INF/** -Xmx4096m -XX:&#43;HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-autoconfigure/target/spring-cloud-azure-autoconfigure-oom.hprof -XX:&#43;CrashOnOutOfMemoryError --add-opens java.base/java.lang.invoke=com.azure.core org.apache.maven.surefire.booter.ForkedBooter /home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-autoconfigure/target/surefire 2025-11-05T03-38-45_939-jvmRun1 surefire-20251105033958921_31tmp surefire_12-20251105033958921_32tmp (dns block)
  • sample.vault.azure.net
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java -javaagent:/home/REDACTED/.m2/repository/org/jacoco/org.jacoco.agent/0.8.13/org.jacoco.agent-0.8.13-runtime.jar=destfile=/home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-autoconfigure/target/jacoco-unit.exec,excludes=META-INF/** -Xmx4096m -XX:&#43;HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-autoconfigure/target/spring-cloud-azure-autoconfigure-oom.hprof -XX:&#43;CrashOnOutOfMemoryError --add-opens java.base/java.lang.invoke=com.azure.core org.apache.maven.surefire.booter.ForkedBooter /home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-autoconfigure/target/surefire 2025-11-05T03-38-45_939-jvmRun1 surefire-20251105033958921_31tmp surefire_12-20251105033958921_32tmp (dns block)
  • test-namespace.servicebus.windows.net
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java -javaagent:/home/REDACTED/.m2/repository/org/jacoco/org.jacoco.agent/0.8.13/org.jacoco.agent-0.8.13-runtime.jar=destfile=/home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-autoconfigure/target/jacoco-unit.exec,excludes=META-INF/** -Xmx4096m -XX:&#43;HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-autoconfigure/target/spring-cloud-azure-autoconfigure-oom.hprof -XX:&#43;CrashOnOutOfMemoryError --add-opens java.base/java.lang.invoke=com.azure.core org.apache.maven.surefire.booter.ForkedBooter /home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-autoconfigure/target/surefire 2025-11-05T03-31-25_112-jvmRun1 surefire-20251105033248445_37tmp surefire_12-20251105033248445_38tmp (dns block)
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java -javaagent:/home/REDACTED/.m2/repository/org/jacoco/org.jacoco.agent/0.8.13/org.jacoco.agent-0.8.13-runtime.jar=destfile=/home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-stream-binder-servicebus/target/jacoco-unit.exec,excludes=META-INF/** -Xmx4096m -XX:&#43;HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-stream-binder-servicebus/target/spring-cloud-azure-stream-binder-servicebus-oom.hprof -XX:&#43;CrashOnOutOfMemoryError --add-opens java.base/java.lang.invoke=com.azure.core org.apache.maven.surefire.booter.ForkedBooter /home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-stream-binder-servicebus/target/surefire 2025-11-05T03-38-45_939-jvmRun1 surefire-20251105034038407_494tmp surefire_14-20251105034038407_495tmp (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@robpt
Copy link
Copy Markdown

robpt commented Dec 4, 2025

@saragluna could we get an update on this one please?

@github-actions
Copy link
Copy Markdown
Contributor

Hi @copilot. Thank you for your interest in helping to improve the Azure SDK experience and for your contribution. We've noticed that there hasn't been recent engagement on this pull request. If this is still an active work stream, please let us know by pushing some changes or leaving a comment. Otherwise, we'll close this out in 7 days.

1 similar comment
@github-actions
Copy link
Copy Markdown
Contributor

Hi @copilot. Thank you for your interest in helping to improve the Azure SDK experience and for your contribution. We've noticed that there hasn't been recent engagement on this pull request. If this is still an active work stream, please let us know by pushing some changes or leaving a comment. Otherwise, we'll close this out in 7 days.

@rujche rujche added azure-spring All azure-spring related issues azure-spring-servicebus Spring service bus related issues. labels Apr 22, 2026
@rujche rujche added this to the 2026-05 milestone Apr 22, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Spring Cloud Azure Service Bus Stream Binder to honor Spring Cloud Stream’s standard consumer retry/backoff properties by wiring a RetryTemplate into inbound message dispatch.

Changes:

  • Add optional retry execution around inbound message handling in ServiceBusInboundChannelAdapter.
  • Build a RetryTemplate in ServiceBusMessageChannelBinder from Spring Cloud Stream consumer properties (or allow injecting a custom template).
  • Add docs/tests covering the new retry configuration behavior.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
sdk/spring/spring-integration-azure-servicebus/src/main/java/com/azure/spring/integration/servicebus/inbound/ServiceBusInboundChannelAdapter.java Adds RetryTemplate support and wraps sendMessage() in retry execution.
sdk/spring/spring-integration-azure-servicebus/CHANGELOG.md Notes the new retry template setter on the inbound adapter.
sdk/spring/spring-cloud-azure-stream-binder-servicebus/src/main/java/com/azure/spring/cloud/stream/binder/servicebus/implementation/ServiceBusMessageChannelBinder.java Creates/configures retry based on consumer properties and supports injecting a custom RetryTemplate.
sdk/spring/spring-cloud-azure-stream-binder-servicebus/src/test/java/com/azure/spring/cloud/stream/binder/servicebus/implementation/ServiceBusRetryTest.java Adds unit tests for retry template presence and custom template injection.
sdk/spring/spring-cloud-azure-stream-binder-servicebus/RETRY_CONFIGURATION.md Adds end-user documentation for retry/backoff properties and custom template injection.
sdk/spring/spring-cloud-azure-stream-binder-servicebus/CHANGELOG.md Notes support for Spring Cloud Stream retry properties and the binder retry template setter.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

@rujche
Copy link
Copy Markdown
Member

rujche commented Apr 24, 2026

@copilot apply changes based on the comments in this thread

…rtion

- Add getRetryTemplate() public getter to ServiceBusMessageChannelBinder,
  matching the same pattern as the existing getter on
  ServiceBusInboundChannelAdapter.
- Update retryTemplateShouldBeWiredWhenBeanProvided in
  ServiceBusBinderConfigurationTests to use binder.getRetryTemplate()
  instead of ReflectionTestUtils.getField(binder, "retryTemplate"),
  removing brittle reflection and validating via the public API.

Agent-Logs-Url: https://github.com/Azure/azure-sdk-for-java/sessions/4132c8e7-88bb-48bc-b279-64842bd4a0fd

Co-authored-by: rujche <171773178+rujche@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 24, 2026

@copilot apply changes based on the comments in this thread

Done in commit 332f819. Added getRetryTemplate() public getter to ServiceBusMessageChannelBinder (matching the existing getter on ServiceBusInboundChannelAdapter) and updated the test to use binder.getRetryTemplate() instead of ReflectionTestUtils.getField(binder, "retryTemplate").

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

@rujche
Copy link
Copy Markdown
Member

rujche commented Apr 27, 2026

@copilot apply changes based on the comments in this thread

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 27, 2026

@rujche Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub.

You can ask me to try again later by mentioning me in a new comment.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: eba0e2e9-551a-43ca-b91b-cbfb6dd2ccd0

Sorry for the inconvenience!

@microsoft-github-policy-service
Copy link
Copy Markdown
Contributor

@copilot the command you issued was incorrect. Please try again.

Examples are:

@ agree

and

@ agree company="your company"

…retry tests

1. ServiceBusInboundChannelAdapter.sendMessageDirectly(): replace
   outputCh.send(message) with getMessagingTemplate().send(outputCh, message)
   so the adapter's configured sendTimeout is respected and
   MessageDeliveryException is still propagated to the RetryTemplate.

2. ServiceBusMessageChannelBinder: extract createExponentialBackOffPolicy()
   from createRetryTemplate() as a package-private method so tests can call
   it directly without reflecting into RetryTemplate internals.

3. ServiceBusRetryTest: replace ReflectionTestUtils.getField(retryTemplate,
   "backOffPolicy") with binder.createExponentialBackOffPolicy(properties).
   Remove now-unused ReflectionTestUtils import.

4. ServiceBusInboundChannelAdapterTests: add two tests for the retry-
   exhausted path:
   - retryTemplateExhaustedWithErrorChannelRoutesToErrorChannel: verify
     exactly one error message is routed to the error channel
   - retryTemplateExhaustedWithoutErrorChannelRethrowsException: verify
     the exception propagates when no error channel is configured

Agent-Logs-Url: https://github.com/Azure/azure-sdk-for-java/sessions/c903f27e-667e-4021-bda8-1a187b34fd8d

Co-authored-by: rujche <171773178+rujche@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 27, 2026

@copilot apply changes based on the comments in this thread

Done in commit fae6b68. Applied all three comments from that review:

  1. sendMessageDirectly sendTimeout semantics — replaced outputCh.send(message) with getMessagingTemplate().send(outputCh, message) so the adapter's configured sendTimeout is respected, matching the non-retry path's behavior.

  2. Retry-exhausted tests — added two tests to ServiceBusInboundChannelAdapterTests:

    • retryTemplateExhaustedWithErrorChannelRoutesToErrorChannel: verifies exactly one ErrorMessage is routed to the error channel after retries are exhausted
    • retryTemplateExhaustedWithoutErrorChannelRethrowsException: verifies the exception propagates to the caller when no error channel is configured
  3. Remove remaining ReflectionTestUtils.getField(retryTemplate, "backOffPolicy") — extracted createExponentialBackOffPolicy() as a package-private method in ServiceBusMessageChannelBinder so ServiceBusRetryTest can call it directly and verify the backoff values via public accessors (getInitialInterval(), getMultiplier(), getMaxInterval()). Removed the ReflectionTestUtils import.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

@rujche
Copy link
Copy Markdown
Member

rujche commented Apr 27, 2026

@copilot apply changes based on the comments in this thread

…in teardown

1. ServiceBusInboundChannelAdapter.sendMessageDirectly(): remove the
   redundant try/catch that just re-threw MessageDeliveryException.
   getMessagingTemplate().send() already propagates the exception;
   the extra wrapping added noise without any behavioral change.

2. ServiceBusRetryTest: move binder construction from final field init
   into @beforeeach so each test gets a fresh, unmodified instance.
   State mutations like binder.setRetryTemplate() in one test can no
   longer leak into subsequent tests regardless of execution order.

3. ServiceBusRetryTest: store the GenericApplicationContext as a field
   and close it in @AfterEach to avoid resource leaks between test runs.

Agent-Logs-Url: https://github.com/Azure/azure-sdk-for-java/sessions/4c3bfec8-0052-463c-9096-b899cad6c134

Co-authored-by: rujche <171773178+rujche@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 27, 2026

@copilot apply changes based on the comments in this thread

Done in commit a123343. Applied all three comments:

  1. Removed the redundant try/catch in sendMessageDirectlygetMessagingTemplate().send() already propagates MessageDeliveryException.
  2. Moved ServiceBusMessageChannelTestBinder construction into @BeforeEach so each test gets a fresh instance with no cross-test state leakage.
  3. Stored the GenericApplicationContext as a field and closed it in @AfterEach to prevent resource leaks.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

@rujche
Copy link
Copy Markdown
Member

rujche commented Apr 27, 2026

@copilot apply changes based on the comments in this thread

1. ServiceBusInboundChannelAdapter: remove unused MessageDeliveryException
   import (the try/catch that used it was removed in a prior commit).

2. ServiceBusBinderConfiguration: qualify the ObjectProvider<RetryTemplate>
   parameter with @qualifier("serviceBusRetryTemplate") so the binder only
   picks up a bean explicitly named serviceBusRetryTemplate. This prevents
   NoUniqueBeanDefinitionException in apps that define multiple RetryTemplate
   beans and documents the injection contract clearly.

3. Update Javadoc for the retryTemplate parameter to state the required bean name.

4. ServiceBusBinderConfigurationTests: register the test bean under the name
   "serviceBusRetryTemplate" to match the new qualifier requirement.

Agent-Logs-Url: https://github.com/Azure/azure-sdk-for-java/sessions/d9cff3b9-7add-4fd3-8995-126b2ff4d69c

Co-authored-by: rujche <171773178+rujche@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 27, 2026

@copilot apply changes based on the comments in this thread

Done in commit 6700e45. Applied both comments:

  1. Unused import — Removed MessageDeliveryException import from ServiceBusInboundChannelAdapter (left orphaned when the try/catch was removed earlier).

  2. Qualifier for RetryTemplate — Added @Qualifier("serviceBusRetryTemplate") to the ObjectProvider<RetryTemplate> parameter in ServiceBusBinderConfiguration.serviceBusBinder(). The binder now only picks up a bean explicitly named serviceBusRetryTemplate, avoiding NoUniqueBeanDefinitionException in apps with multiple RetryTemplate beans. Updated the Javadoc and the test bean registration to match.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

Copy link
Copy Markdown
Member

@Netyyyy Netyyyy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rujche
Copy link
Copy Markdown
Member

rujche commented Apr 28, 2026

@copilot resolve the merge conflicts in this pull request

Resolve merge conflict in sdk/spring/CHANGELOG.md:
- Keep the Spring Cloud Azure Autoconfigure section (from main) with the
  passwordless JDBC/Redis scope bug fix
- Keep the Spring Cloud Azure Stream Binder Service Bus section (from our
  branch) with the retry feature entries
- Drop the empty ### Breaking Changes / ### Bugs Fixed / ### Other Changes
  placeholders that main replaced with module-specific sections

Agent-Logs-Url: https://github.com/Azure/azure-sdk-for-java/sessions/1db09201-c1f0-47e3-945e-eeb46180d259

Co-authored-by: rujche <171773178+rujche@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 28, 2026

@copilot resolve the merge conflicts in this pull request

Done. Merged origin/main and resolved the single conflict in sdk/spring/CHANGELOG.md — both the Spring Cloud Azure Autoconfigure section (from main's passwordless scope fix) and our Spring Cloud Azure Stream Binder Service Bus section are now present under 7.3.0-beta.1 (Unreleased).

@rujche
Copy link
Copy Markdown
Member

rujche commented Apr 28, 2026

@copilot resolve the merge conflicts in this pull request

…ries

Co-authored-by: rujche <171773178+rujche@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 28, 2026

@copilot resolve the merge conflicts in this pull request

Done in commit af105d7b. Merged latest origin/main and resolved the sdk/spring/CHANGELOG.md conflict — both the Spring Cloud Azure Autoconfigure section (from main) and the Spring Cloud Azure Stream Binder Service Bus retry feature section are now present under 7.3.0-beta.1 (Unreleased).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

azure-spring All azure-spring related issues azure-spring-servicebus Spring service bus related issues.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[FEATURE REQ] Make ServiceBus Binder honor the Spring Stream back-off settings

6 participants